/* pts02Handshake.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pts02Handshake.h>
#include <wrapper/JavaStreamWrapper.h>

pts02Handshake::pts02Handshake()
    : McPacketToServer(0x02), username("")
{
}

pts02Handshake::pts02Handshake(std::string username)
    : McPacketToServer(0x02), username(username)
{
}

unsigned int pts02Handshake::length()
{
    return 1 + 2 + username.length();
}

void pts02Handshake::forge(std::ostream& out)
{
    JavaStreamWrapper jsw(out);

    jsw.writeByte(getPacketId());
    jsw.writeUTF(username);

}

std::string pts02Handshake::getUsername()
{
    return username;
}


void pts02Handshake::setUsername(std::string username)
{
    this->username = username;
}


